package subject_set.offer100;

/**
 * @author haomin
 * @date 2022/10/14 22:20
 **/
public class Offer21 {
    class Solution {
        public int[] exchange(int[] nums) {
            int l = 0, r = nums.length-1;
            while(l < r){
                while(l < r && nums[l] % 2 != 0) l++;
                while(l < r && nums[r] % 2 == 0) r--;
                if(l < r){
                    int tem = nums[l];
                    nums[l] = nums[r];
                    nums[r] = tem;
                }
            }
            return nums;
        }
    }
}